<?php


namespace App\Http\Middleware;

use App\Services\Token;
use Closure;
use Illuminate\Http\Request;

class VerifyToken
{
    /**
     * Handle an incoming request.
     *
     * @param \Illuminate\Http\Request $request
     * @param \Closure $next
     * @return mixed
     */
    public function handle(Request $request, Closure $next)
    {
        $referer = $request->header('referer');
        $token = $request->header('Authorization');
//        if (strstr($referer, 'apidoc') && $token=='Bearer') {
//            return $next($request);
//        }
        (new Token())->verifyToken($request);
        return $next($request);
    }
}
